import random

import pyautogui
import pydirectinput


def reset():
    """重置鼠标位置"""
    pydirectinput.moveTo(random.randint(100, 400),
                         random.randint(100, 700), )


def duration():
    """延迟时间"""
    return random.uniform(0.3, 0.5)


def next_tick(rate=1):
    """操作间隔"""
    pyautogui.sleep(random.uniform(0.1, 0.3) * rate)


def move_args():
    """移动参数"""
    return {
        'duration': duration()
    }


def do_move(point):
    """移动鼠标"""
    pydirectinput.moveTo(*point, **move_args())


def move_left(point):
    """移动鼠标并点击左键"""
    pydirectinput.leftClick(*point, **move_args())


def move_right(point):
    """移动鼠标并点击右键"""
    pydirectinput.rightClick(*point, **move_args())


def only_left():
    pydirectinput.leftClick()


def only_right():
    """原地右键单击"""
    pydirectinput.rightClick()


def press(key):
    """按键盘"""
    pydirectinput.press(key)


def shift_click(point):
    """shift+左键单击"""
    pydirectinput.keyDown('shift')
    next_tick()
    move_left(point)
    pydirectinput.keyUp('shift')


def tab_win():
    pydirectinput.keyDown('alt')
    press('esc')
    pydirectinput.keyUp('alt')


if __name__ == '__main__':
    pyautogui.sleep(3)

    do_move((273, 475))
